package com.yansu.own.entity.pojo;

import lombok.Data;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import java.beans.Transient;
import java.util.Date;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;

@Data
public class SysUser extends BasePojo{
    private static final long serialVersionUID = 1L;
    private Long userId;
    /**
     * 姓名
     */
    private String userName;

    /**
     * 工号
     */
    private String jobNum;

    /**
     * 部门
     */
    private String deptName;

    /**
     * 职位
     */
    private String dutyName;

    /**
     * 备注
     */
    private String remark;
    private String phone;
    private String email;
    private String sex;
    private String avatar;
    private String delFlag;
    private String loginIp;
    private Date loginDate;

    /**
     * 关联产品
     */
    private String modulesStr;

    /**
     * 关联端
     */
    private String client;

    /**
     * 关联功能角色
     */
    private String rolesStr;

    /**
     * 关联数据角色
     */
    private String dataRolesStr;

    /**
     * 首页模板
     */
    private String appTemplate;

    /**
     *  帐号状态，0=启用，1=禁用
     */
    private Integer status;
    //private List<SysRole> roles;
    private Long[] roleIds;
    private Long[] appRoleIds;
    private Long roleId;
    private Long moduleId;
    private Long[] moduleIds;
    private Long[] dataRoleIds;
    private Integer templateId;
    private Integer[] templateIds;

    public SysUser() {
    }

    public SysUser(Long userId) {
        this.userId = userId;
    }

    public Long getUserId() {
        return this.userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    @Transient
    public boolean isAdmin() {
        return isAdmin(this.userId);
    }

    public static boolean isAdmin(Long userId) {
        return userId != null && 1L == userId;
    }

    public String getDeptName() {
        return this.deptName;
    }

    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }

    public String getJobNum() {
        return this.jobNum;
    }

    public void setJobNum(String jobNum) {
        this.jobNum = jobNum;
    }

    @NotBlank(
            message = "用户账号不能为空"
    )
    @Size(
            min = 0,
            max = 30,
            message = "用户账号长度不能超过30个字符"
    )
    public String getUserName() {
        return this.userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    @Email(
            message = "邮箱格式不正确"
    )
    @Size(
            min = 0,
            max = 50,
            message = "邮箱长度不能超过50个字符"
    )
    public String getEmail() {
        return this.email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    @Size(
            min = 0,
            max = 11,
            message = "手机号码长度不能超过11个字符"
    )
    public String getPhone() {
        return this.phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getSex() {
        return this.sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getAvatar() {
        return this.avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public String getModulesStr() {
        return this.modulesStr;
    }

    public void setModulesStr(String modulesStr) {
        this.modulesStr = modulesStr;
    }

    public String getRolesStr() {
        return this.rolesStr;
    }

    public void setRolesStr(String rolesStr) {
        this.rolesStr = rolesStr;
    }

    public Integer getStatus() {
        return this.status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getDelFlag() {
        return this.delFlag;
    }

    public void setDelFlag(String delFlag) {
        this.delFlag = delFlag;
    }

    public String getLoginIp() {
        return this.loginIp;
    }

    public void setLoginIp(String loginIp) {
        this.loginIp = loginIp;
    }

    public Date getLoginDate() {
        return this.loginDate;
    }

    public void setLoginDate(Date loginDate) {
        this.loginDate = loginDate;
    }

    public Long[] getRoleIds() {
        return this.roleIds;
    }

    public void setRoleIds(Long[] roleIds) {
        this.roleIds = roleIds;
    }

    public Long getRoleId() {
        return this.roleId;
    }

    public void setRoleId(Long roleId) {
        this.roleId = roleId;
    }

    public Long getModuleId() {
        return this.moduleId;
    }

    public void setModuleId(Long moduleId) {
        this.moduleId = moduleId;
    }

    public Long[] getModuleIds() {
        return this.moduleIds;
    }

    public void setModuleIds(Long[] moduleIds) {
        this.moduleIds = moduleIds;
    }

    public Long[] getDataRoleIds() {
        return this.dataRoleIds;
    }

    public void setDataRoleIds(Long[] dataRoleIds) {
        this.dataRoleIds = dataRoleIds;
    }

    public String getDataRolesStr() {
        return this.dataRolesStr;
    }

    public void setDataRolesStr(String dataRolesStr) {
        this.dataRolesStr = dataRolesStr;
    }

    public String getDutyName() {
        return this.dutyName;
    }

    public void setDutyName(String dutyName) {
        this.dutyName = dutyName;
    }

    public String getRemark() {
        return this.remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String getAppTemplate() {
        return this.appTemplate;
    }

    public void setAppTemplate(String appTemplate) {
        this.appTemplate = appTemplate;
    }

    public String getClient() {
        return this.client;
    }

    public void setClient(String client) {
        this.client = client;
    }

    public Integer getTemplateId() {
        return this.templateId;
    }

    public void setTemplateId(Integer templateId) {
        this.templateId = templateId;
    }

    public Long[] getAppRoleIds() {
        return this.appRoleIds;
    }

    public void setAppRoleIds(Long[] appRoleIds) {
        this.appRoleIds = appRoleIds;
    }

    public Integer[] getTemplateIds() {
        return this.templateIds;
    }

    public void setTemplateIds(Integer[] templateIds) {
        this.templateIds = templateIds;
    }

    public String toString() {
        return (new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)).append("userId", this.getUserId()).append("userName", this.getUserName()).append("deptName", this.getDeptName()).append("jobNum", this.getJobNum()).append("email", this.getEmail()).append("phone", this.getPhone()).append("sex", this.getSex()).append("avatar", this.getAvatar()).append("status", this.getStatus()).append("delFlag", this.getDelFlag()).append("loginIp", this.getLoginIp()).append("loginDate", this.getLoginDate()).append("createBy", this.getCreateBy()).append("createTime", this.getCreateTime()).append("updateBy", this.getUpdateBy()).append("updateTime", this.getUpdateTime()).append("remark", this.getRemark()).toString();
    }
}
